CREATE PROCEDURE coreWFProcessSave
(
	@id					int output,
	@FK_DefinitionID	int,
	@ProcessName		nvarchar(500),
	@ProcessType		int,
	@DataCanView		bit,
	@DataCanEdit		bit,
	@Rank				int
)
AS
BEGIN

	IF @id = -1
	BEGIN
		SET NOCOUNT ON;

		INSERT INTO WFProcess 
		(
			FK_DefinitionID,
			ProcessName,
			ProcessType,
			DataCanView,
			DataCanEdit,
			Rank
		)
		VALUES
		(
			@FK_DefinitionID,
			@ProcessName,
			@ProcessType,
			@DataCanView,
			@DataCanEdit,
			@Rank
		);

		SET NOCOUNT OFF;
		SELECT @id = @@IDENTITY;

	END
	ELSE
	BEGIN
		
		UPDATE WFProcess SET
			ProcessName		= @ProcessName,
			ProcessType		= @ProcessType,
			DataCanView		= @DataCanView,
			DataCanEdit		= @DataCanEdit,
			Rank			= @Rank
		WHERE PK_ID=@id;	
		
	END
	
END
